// PgrsStatusBar.cpp : implementation file
//

#include "stdafx.h"
#include "TSG.h"
#include "PgrsStatusBar.h"


// CPgrsStatusBar

IMPLEMENT_DYNAMIC(CPgrsStatusBar, CStatusBar)

CPgrsStatusBar::CPgrsStatusBar()
{

}

CPgrsStatusBar::~CPgrsStatusBar()
{
}


BEGIN_MESSAGE_MAP(CPgrsStatusBar, CStatusBar)
	ON_WM_CREATE()
	ON_WM_SIZE()
END_MESSAGE_MAP()



// CPgrsStatusBar message handlers



int CPgrsStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{	
	if(lpCreateStruct)
	{
		lpCreateStruct->style |= WS_CLIPCHILDREN;
	}
	if (CStatusBar::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	

	if (m_progress.Create(WS_CHILD, CRect(), this, ID_PROGRESS) == FALSE)
	{
		return -1;
	}

	m_progress.SetRange(0, 100);
	
	return 0;
}

void CPgrsStatusBar::OnSize(UINT nType, int cx, int cy)
{
	CStatusBar::OnSize(nType, cx, cy);

	// TODO: Add your message handler code here	
	CRect rc;
	GetItemRect(1, &rc);
	m_progress.MoveWindow(&rc, FALSE);
}

void CPgrsStatusBar::SetProgress(UINT nProgress)
{
		m_progress.SetPos(nProgress);
}

void CPgrsStatusBar::ShowProgressBar(void)
{
	CWnd* hWnd = GetDlgItem(ID_PROGRESS);
	if (hWnd != NULL)
	{
		hWnd->ShowWindow(SW_SHOW);
	}
}
void CPgrsStatusBar::HideProgressBar(void)
{	
	CWnd* hWnd = GetDlgItem(ID_PROGRESS);
	if (hWnd != NULL)
	{
		hWnd->ShowWindow(SW_HIDE);
	}
}
